<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>现货发售交易登录</title>
<%@ include file="/common/sale/include/common-base.jsp"%>
<script type="text/javascript" src="${ctx}/js/jquery-md5-min.js"></script>
<script type="text/javascript">
	function viewVerifyCode() {
		var r = "";
		if (undefined != ctx)
			r = ctx;
		document.getElementById("verifyCode").style.visibility = "visible";
		document.getElementById("verifyCode").src = ctx + "/web/CheckRandCode?" + Math.random();
	}
</script>
</head>
<style>
* {
	padding: 0;
	margin: 0;
}

.login_title {
	color: #dc8a29;
	font-size: 30px;
	padding: 20px 0;
}

.login_title p {
	display: inline-block;
	padding-right: 10px;
	border-right: 3px solid #dc8a29;
}

.login_title span {
	display: inline-block;
	font-size: 14px;
	color: #dc8a29;
	padding-left: 10px;
}

.login_wrap {
	background: url("/images/sale/banner-bj.jpg") no-repeat;
	background-size: 100% 400px ;
	height:400px;
}

.login-box {
	height: 365px;
	background: #fff;
	box-shadow: 0 1px 1px #ddd;
}

.login-box h6 {
	text-align: center;
	font-weight: bold;
	font-size: 18px;
	color: #214349;
	padding: 20px 0;
}

#inputForm {
	padding: 0 30px;
}

#inputForm .form-group:last-child {
	margin-top: 15px;
}

.login_btn {
	margin: 0px 15px 0 15px;
	color: #a5a8aa;
	padding: 10px 15px 0 15px
}

.login_btn a {
	color: #a5a8aa
}

.login_btn button {
	padding: 10px 0;
}

.form-control-feedback {
	left: 0;
	top: 7px;
	color: #aaaaaa;
}

.has-feedback .form-control {
	color: #aaaaaa;
	height: 45px;
	padding: 10px 0 10px 30px;
}

.form-control:focus {
	border: 1px solid #88a8c1;
	box-shadow: 2px 2px 5px rgba(136, 168, 193, .5);
}

.footer {
	color: #969696;
	margin: 40px 0;
}

.has-feedback .form-control {
	color: #333;
	height: 45px;
	padding: 10px 0 10px 30px;
}

.regs a:hover {
	color: #dc8a29;
	text-decoration: underline;
	cursor: pointer;
}
</style>


<body>
	<div class="container">
		<h1 class="login_title">
			<p>现货发售交易</p> <span style="color:#214349;">交易用户登录</span>
		</h1>
	</div>
	<div class="login_wrap">
		<div class="container">
			<div class="row">
				<div class="col-md-6"></div>
				<div class="col-md-1"></div>
				<div class="col-md-4">
					<!-- login start -->
					<!-- /.login-logo -->
					<div class="login-box">
						<h6>登录信息</h6>
						<form action="" method="post" id="inputForm" name="inputForm">
							<input id="password_form" name="password" type="hidden" />
							<input id="randCode_form" name="rand" type="hidden" /> 
							<input id="username_form" name="username" type="hidden" />
							<div class="form-group has-feedback">
								<input id="userEname" class="form-control fft" tabindex="1"
									placeholder="输入用户名" type="text" value="" /> <span
									class="glyphicon glyphicon-envelope form-control-feedback"></span>
							</div>
							<div class="form-group has-feedback">
								<input type="password" id="upass" class="form-control fft"
									placeholder="输入密码" value=""> <span
									class="glyphicon glyphicon-lock form-control-feedback"></span>
							</div>

							<div class="form-group has-feedback">
								<input id="rand" size="4" style="width:60%; margin-right:5px;"
									class="form-control"> <input name="flagDiv"
									id="flagDiv" type="hidden" value="" /> <img border=0
									id="verifyCode" src="" onclick="viewVerifyCode();"
									align="absmiddle" />
								<script>
									viewVerifyCode();
								</script>
								<span class="glyphicon glyphicon-pencil form-control-feedback"></span>
							</div>
						</form>

						<div id="error-message" style="padding-left:32px;">&nbsp;</div>
						<div class="login_btn">
							<div class="social-auth-links text-center">
								<button id="btn-login" type="button" class="btn btn-block  btn-warning"
									onclick="sumbit()">登 录</button>
							</div>
							<div class="social-auth-links text-center regs">
								<a href="${ctx}/sendPage/sale/web/user/regIndexT?sysFlag=sale">注册</a>&nbsp;|&nbsp;
     	 		                <a href="javascript:resPassIndexSale();">找回密码</a> 

							</div>
						</div>
						<!-- /.login-box-body -->
						<!-- login end -->

					</div>
				</div>
			</div>
		</div>
		<footer class="footer">
			<center> Copyright © 2017 , Inc. All rights reserved.
			</center>
		</footer>
</body>

<script type="text/javascript">
	//解决ie不支持trim
	$(document).ready(function() {
		if (!String.prototype.trim) {
			String.prototype.trim = function() {
				return this.replace(/^\s+|\s+$/g, '');
			};
		}
	});
	//回车登录
	document.onkeydown = function mykeyDown(e) {
		//compatible IE and firefox because there is not event in firefox  
		e = e || event;
		if (e.keyCode == 13) {
			sumbit();
		}
		return;
	};
	//登录操作
	function sumbit() {
		var uname = $('#userEname').val();
		var upass = $('#upass').val();
		if (uname == null || uname == "") {
			setErrMsg('请输入用户名');
			$('#userEname').focus();
			return;
		}
		if (upass == null || upass == "") {
			setErrMsg('请输入密码');
			$('#upass').focus();
			return;
		}
		$("#password_form").val(upass.md5());
		$("#randCode_form").val($("#rand").val());
		$("#username_form").val(uname);
		var formUrl = ctx + "/res/uct/login";
		//数据提交
		$.ajax({
			url : formUrl,
			type : 'post',
			data : $("#inputForm").serialize(),
			success : function(data) {
				console.log(data);
				var jdata = jQuery.parseJSON(data);
				if (jdata.flag == 'T') {
					//$("#btn-login").prop('disabled', true); 
					sendJump();
					/**
					$("#btn-login").text("登录成功，正在跳转...");
					var msgIndex = layer.msg("登录成功，正在跳转...", {closeBtn: 0,offset: '220px'});
					$.ajax({
						url : ctx+"/res/uct/userInfo",type : 'post',data : $("#inputForm").serialize(),
						success : function(data) {
							console.log(data);
							var udata = jQuery.parseJSON(data);
							if (udata.msg.length > 0) {
								if ("manager" == udata.msg) {
									window.location.href = "${ctx}/sendPage/sale/admin/index";
								} else if ("member" == udata.msg) {
									window.location.href = "${ctx}/sendPage/sale/web/user/index";
								}else{
									layer.close(msgIndex);
									layer.alert("无权限继续访问！");
									//$("#btn-login").prop('disabled', false);
									location.reload();
									document.getElementById("inputForm").reset(); 
								}
							}
						}
					});
					**/
					
				} else {
					setErrMsg(jdata.msg);
					clearForm();
				}
			},
			error : function(data) {
				setErrMsg('与服务器连接失败');
			}
		});
	}

	//清空表单数据
	function clearForm() {
		$("#upass").val("");
		$("#userEname").val("");
	}

	function setErrMsg(msg) {
		$("#error-message").html("<font color='red'>" + msg + "</font>");
	}
	function resPassIndexSale(){
		layer.open({
		    type: 2,
		    title: '找回密码',
		    shadeClose: false,
			offset: '40px',
		    shade: 0.6,
		    area: ['580px', '510px'],
		    content: '${ctx}/sendPage/bjte/web/user/resPassIndex' //iframe的url
		}); 
	}
	//登录跳转
	function sendJump(){
		layer.open({
		    type: 2,
		    title: false,
		    shadeClose: false,
		    closeBtn: 0,
			offset: '230px',
		    shade: 0.6,
		    area: ['250px', '80px'],
		    content: '${ctx}/sendPage/sale/login-jump' //iframe的url
		}); 
	}
</script>
</html>